import React from 'react';
import FindInPageOutlined from '@material-ui/icons/FindInPageOutlined';
import { NavView, get_mod, loc, NavListSub } from 'sui';
import { LatheView, ForgeView, CeraView, StellView, SealView, CageView } from './base/view';
import { get_access } from 'cache';

const model = (cfg) => {
    const fix = [
        {uid: "test.cage", view: CageView, value: loc("l_528")},
        {uid: "test.seal", view: SealView, value: loc("l_529")},
        {uid: "test.stell", view: StellView, value: loc("l_712")},
        {uid: "test.cera", view: CeraView, value: loc("l_713")},
        {uid: "test.lathe", view: LatheView, value: loc("l_894")},
        {uid: "test.forge", view: ForgeView, value: loc("l_893")},
    ];

    let ret = get_mod(cfg, fix, "test");
    let acc = get_access();

    if (acc && ret) {
        ret = ret.filter(d => acc.has(d.uid));
    }

    return ret;
};

const Test = ({ mod, sideopen, cfg }) => <NavView cfg={cfg} model={model(cfg)} mod={mod} sideopen={sideopen} name="test"/>;

const NavTest = (props) => <NavListSub icon={<FindInPageOutlined/>} sub={model(props.cfg)} {...props} scut={15}/>;

export {NavTest, Test};
